package com.zlk.algorithm.huawei.nowcoder;

import java.io.*;

/**
 * @program: algorithm
 * @ClassName Test
 * @description:
 * @author: slfang
 * @create: 2024-12-20 17:19
 * @Version 1.0
 **/
public class Test {





        public static void main(String[] args) {
            StringReader reader = new StringReader("A;as;aa");
            StreamTokenizer tokenizer = new StreamTokenizer(reader);

            try {
                while (tokenizer.nextToken() != StreamTokenizer.TT_EOF) {
                    if (tokenizer.ttype == StreamTokenizer.TT_WORD) {
                        // 输出已解析的字符串
                        System.out.println("Word: " + new String(tokenizer.sval));
                    } else if (tokenizer.ttype == ';') {
                        System.out.println("Delimiter: ;");
                    } else {
                        System.out.println("Other token: " + (char) tokenizer.ttype);
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
}
